package com.webserver.core;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

/**
 * 该线程任务负责与指定的客户端完成HTTP交互
 */
public class ClientHandler implements Runnable{
    private Socket socket;
    public ClientHandler(Socket socket){
        this.socket =socket;
    }
    @Override
    public void run(){
        try {
            InputStream is = socket.getInputStream();//电信号转换为2进制
            int d;
            while ((d=is.read())!=-1){//读一位二进制数并判断是不是读完了
                System.out.print((char)d);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
